<%@ include file="IsProff.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <%@ include file="../master/head.jsp"%>
    </head>
    <body>
				<script>
			 function isCorrect(t)
			 {
				 inno = document.getElementById('incorrectFields');
				 if (t.fn.value == '' )					
					 {	inno.innerHTML = 'Invalid First Name';return false;}
				 else if ( t.mn.value == '' )
					 {	inno.innerHTML = 'Invalid Father Name';return false;}
				 else if ( t.ln.value == '' )
					 {	inno.innerHTML = 'Invalid Last Name';return false;}
				 else if ( t.login.value == '' )
					 {	inno.innerHTML = 'Invalid Username';return false;}
				 else if ( t.pwd.value == '' )
					 {	inno.innerHTML = 'Invalid Password';return false;}
				 else if ( t.pwd.value != t.rpwd.value)
					 {	inno.innerHTML = 'Passwords not matches.';return false;}
				 else if ( !isEmail(t.email.value) )
					 {	inno.innerHTML = 'Invalid Email';return false;}
				 else	
					 return true;
				 
				 
			 }
			 function isEmail(t)
			 {
				 if (t.indexOf('.') > t.indexOf('@')+1 && t.indexOf('@') > 0)
					 return true;
				 else
					 return false;
			 }
		</script>
        <div id="container">
            <div id="wrapper">
                <div id="sidebar">
                    <div id="sb_top"><%@ include file="../master/sbTop.jsp"%>
                    </div>
                    
                    <div class="sb_content"><!--##########--> <!-- Start Menu --> <%@ include
         file="../master/Profmenu.jsp"%> <!-- Profile -->
<%@ include file="../master/profile.jsp"%> <!-- links -->
<%@ include file="../master/links.jsp"%>
                        <div class="copyright"><%@ include file="../master/copyright.jsp"%>
                        </div>
                        
                    </div>
                <!-- /sb_content --></div>
                <!-- /sidebar --> <!-- Top -->
                <div id="header"><%@ include file="../master/header.jsp"%>
                </div>
                
                
                <!-- Start main content -->
                <div id="content">
                    <div id="intro">
                        <div class="intro_t">
                            <h1><span>..</span>Welcome to<span>..</span></h1>
                            <h2>student project managment system</h2>
                            
                        </div>
                    </div>
                    <!-- /intro --> <%@ page import="java.sql.*, database.*"%>
 <h1>Professor Information</h1>
<%
try{
        DBCon db = new DBCon();
    String control = db.getControlValue("professor_update");
    
    if(control.equals("true"))
    {
           ResultSet res = new DBCon().getProf(",userlogin WHERE professor.username = userlogin.username and ID =" + session.getAttribute("ProfID"));
            if (res.next()) {
%>
                    <form name="UpdateProfile" action="../DB/updateProfile.jsp" method="post" onsubmit="return isCorrect(this)">
                        <table border="0" id="tabM">
                            <tr>
                                <td class="style1">
                                   
                                </td>
																	<td>
										<div id='incorrectFields' class='required'></div>
									</td>

                            </tr>
                            <tr>
                                <td>
                                    <hr />
                                </td>
                                <td>
                                    <hr />
                                </td>
                            </tr>
                            
                            <tr>
                                <td class="required">Name</td>
                                <td><input type="text" name="fn" size="10" value="<%= res.getString("FirstName")%>"/><input type="text"
                                                                                                                            name="mn" size="10" value="<%= res.getString("MiddleName")%>"/><input type="text" name="ln" size="10" value="<%= res.getString("LastName")%>"/></td>
                            </tr
                            <tr>
                                <td>Degree</td>
                                
                                
                                <%
                String deg = res.getString("degree");

                String le = "", ap = "", asp = "", fp = "";
                if (deg.equals("Lecturer")) {
                    le = "selected";
                } else if (deg.equals("Assistant")) {
                    ap = "selected";
                } else if (deg.equals("Associate")) {
                    asp = "selected";
                } else if (deg.equals("Full")) {
                    fp = "selected";
                }
                                %>
                                <td><select name="deg"  >
                                        <option value="Lecturer" <%=le%> >Lecturer</option>
                                        <option value="Assistant" <%=ap%> >Assistant Professor</option>
                                        <option value="Associate" <%=asp%> >Associate Professor</option>
                                        <option value="Full"  <%=fp%> >Full Professor</option>
                                </select></td>
                            </tr>
                            <tr>
                                
                                <%
                String dep = res.getString("department");
                String cs = "", is = "";
                if (dep.equals("CS")) {
                    cs = "selected";
                } else if (dep.equals("IS")) {
                    is = "selected";
                }
				String pass = res.getString("password");
				String usr = res.getString("professor.username");
                                %>
                                <td>Department</td>
                                <td><select name='dpt' >
                                        <option value='CS' <%=cs%> >Computer Science</option>
                                        <option value='IS' <%=is%> >Information Systems</option>                                
                                </select></td>
                                
                            </tr>
                            <tr>
                                <td>Work Phone</td>
                                <td><input type="text" name="wp" size="30" value="<%= res.getString("workPhone")%>"/></td>
                            </tr>
                            <tr>
                                <td>Mobile Phone</td>
                                <td><input type="text" name="mp" size="30" value="<%= res.getString("MobilePhone")%>"/></td>
                            </tr>
                            <tr>
                                <td class="required">Email</td>
                                <td><input type="text" onblur="isEmail(this.value)" name="email" size="30" value="<%= res.getString("Email")%>"/></td>
                            </tr>
                            <tr>
                                <td>Home page</td>
                                <td><input type="text" name="hp" size="30" value="<%= res.getString("HomePage")%>"/></td>
                            </tr>
                            
                            <tr>
                                <td>
                                    <hr />
                                </td>
                                <td>
                                    <hr />
                                </td>
                            </tr>
                            <tr>
                                <td class="style1">
                                    <h2>User Account</h2>
                                </td>
                            </tr>
                            <tr>
                                <td>Login</td>
                                <td><input disabled type="text" size="15" value="<%= usr %>" />
										   <input disabled type="hidden" name="login" value="<%= usr %>" />
										   </td>
                            </tr>
                            <tr>
                                <td>Password</td>
                                <td><input type="password" name="pwd" size="15"
                                           value="<%= pass%>" /></td>
                            </tr>
                            <tr>
                                <td>Re-Password</td>
                                <td><input type="password" name="rpwd" size="15" value="<%= pass%>"/></td>
                            </tr>
                            <tr>
                                <td><input type="submit" value="Update Profile" /></td>
                                <td></td>
                            </tr>
                        </table>
                    </form>
                    <%
            }
           }else{%>
<br/><br/><center><h2> This service is not availabe now </h2></center>
<%}
}
catch(Exception e)
{
    response.sendRedirect("../connectionFailed.jsp?"+e);
}
                    %>
                </div>
            <!-- /content --></div>
            <!-- /wrapper -->
            <div class="clear">&nbsp;</div>
        <!-- Important! Fix the problem of height in Firefox --></div>
        <!-- /Container -->

        
    </body>
</html>